<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function remove(arr, n) {
            var n_arr = new Array();
            var j = 0;
            for (var i = 0; i < arr.length; i++) {
                if (arr[i] != n) {
                    n_arr[j] = arr[i];
                    j++;
                }
            }
            return n_arr;
        }

        function other_remove(arr, n) {
            var r = arr.filter(function(x) {
                return x != n;
            });
            return r;
        }
        var arr = new Array(1, 4, 5, 2, 3, 9, 2, 7, 2, 5);
        document.write(remove(arr, 2) + "<br>");
        document.write(other_remove(arr, 2) + "<br>");
    </script>
</body>

</html>